package com.example.administrator.daydayappmarket.software.rating.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.daydayappmarket.R;
import com.example.administrator.daydayappmarket.software.rating.fragment.adapter.RatingViewPagerAdapter;
import com.example.administrator.daydayappmarket.software.rating.fragment.hotrating.fragment.RatingHotFragment;
import com.example.administrator.daydayappmarket.software.rating.fragment.newrating.fragment.RatingNewFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * A simple {@link Fragment} subclass.
 */
public class SWRatingFragment extends Fragment {


    @InjectView(R.id.fragment_rating_tabLayout)
    TabLayout fragmentRatingTabLayout;
    @InjectView(R.id.fragment_rating_viewPager)
    ViewPager fragmentRatingViewPager;

    public SWRatingFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_swrating, container, false);
        ButterKnife.inject(this, view);
        List<Fragment> fragments=new ArrayList<>();
        fragments.add(new RatingNewFragment());
        fragments.add(new RatingHotFragment());

        List<String> titles=new ArrayList<>();
        titles.add(getString(R.string.fragment_rating_new));
        titles.add(getString(R.string.fragment_rating_hot));

        RatingViewPagerAdapter adapter=new RatingViewPagerAdapter(getChildFragmentManager(),titles,fragments);

        fragmentRatingViewPager.setAdapter(adapter);
        fragmentRatingTabLayout.setupWithViewPager(fragmentRatingViewPager);



        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}
